package com.xc.stock.domain.basic.entity;

import com.ag.utils.NumberUtils;
import com.ag.utils.SysConstant.BooleanEnum;
import com.xc.stock.constant.AppVersionType;
import com.xc.stock.infrastructure.db.po.AppVersionPO;
import com.xc.stock.utils.Beans;

import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.experimental.SuperBuilder;

/**
 * AppVersionEntity
 *
 * @author xlfd
 * @email xlfd@gmail.com
 * @created 2021/10/25
 */
@Data
@NoArgsConstructor
@SuperBuilder
@EqualsAndHashCode(callSuper = false)
public class AppVersion extends AppVersionPO {
	public <E extends AppVersionPO> void update(E cmd) {
		Beans.copyPropertiesIgnoreNull(cmd, this);
		
		AppVersionType versionType = AppVersionType.of(cmd.getType());
		setType(versionType.code());
        setTypeName(versionType.remark());
	}
	
	public boolean mustUpdate() {
		return BooleanEnum.isOn(NumberUtils.parseInt(getMustUpdate(), 0));
	}
}
